import { PartialType } from '@nestjs/swagger';
import { Decorator_DtoIsNumber_Base } from '@/common/decorators/dtoIsNumber';
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
import {
  Constant_Enum_Enum_ExCode_ExCodeValue,
  Constant_Enum_Name_ExCode_ExCodeValue,
  IConstant_Enum_Type_ExCode_ExCodeValue,
} from '@/common/constants/enum';

export class ExCode_Create_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ description: '兑换码数量' })
  exCodeNum: number;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ description: '优惠券Id' })
  couponId: number;
}

export class ExCode_Find_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  size?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  page?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  couponId?: number;

  @IsString()
  @IsOptional()
  @ApiProperty({
    enum: Constant_Enum_Enum_ExCode_ExCodeValue,
    description: '兑换码状态' + Constant_Enum_Name_ExCode_ExCodeValue,
  })
  exCodeStatus?: IConstant_Enum_Type_ExCode_ExCodeValue;
}

export class ExCode_Update_Dto extends PartialType(ExCode_Create_Dto) {
  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  id: number;
}

export class ExCode_ExChange_Dto {
  @IsString()
  @IsNotEmpty()
  @ApiProperty({ description: '兑换码值' })
  exCode: string;
}
